<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('备课')"/>
    <th:block th:include="include :: select2-css"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <style>
        .form-control {
            width: 118px;
            margin-bottom: 4px;
        }

        .train-account {
            display: none;
        }

        .complete-times {
            font-size: 5px;
            color: #999;
            margin-left: 2px;
        }

        select[id^="init"] {
            display: inline;
        }

        .link-require {
            background: rgba(255, 0, 0, 0.06);
        }

        .allLink {
            padding: 1px 0px;
            line-height: 1;
            background-color: #e5e2e2;
        }
        .showDifficulty {
            padding: 1px 3px;
            line-height: 1;
            background-color: red;
            margin-left: 3px;
            color: white;
            font-size: 13px;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="col-sm-12 search-collapse">
        <form id="data-form">
            <input id="childCourseId" name="childCourseId" th:value="*{childCourseId}" hidden="true">
            <input id="ageGrade" name="ageGrade" th:value="*{ageGrade}" hidden="true">
        </form>
    </div>
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="completePrepare()">
                <i class="fa fa-check"></i>完成备课
            </a>
            <a class="btn btn-success" onclick="replaceInitLink()">
                <i class="fa fa-retweet"></i>替换项目
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    // 权限

    // 字典

    var prefix = ctx + "business/prepareClass";

    $(function () {
        var options = {
            url: prefix + "/childList",
            modalName: "数据",
            columns: [
                {
                    field: 'childName',
                    title: '姓名',
                    formatter: function (value, row, index) {
                        if (row.childId == 0) {
                            return '全部学员';
                        }
                        return value + "(" + row.age + ")";
                    }
                },
                {
                    field: 'linkOne',
                    title: '引入1',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initOne != null && row.initOne != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initOne_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initOne_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            } else {
                                actions += '<select  class=\'form-control\' id="initOne_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initOne_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            }
                            for (var i in row.linkOneOptions) {
                                var obj = row.linkOneOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_1_' + row.childId + '"></span>';
                        actions += '<a class="btn btn-default btn-xs allLink"  onclick="allLink(' + row.childId + ',\'initOne_\',\'' + row.initOne + '\',' + row.childCourseId + ')">全员</a>';
                        return actions;
                    }
                },
                {
                    field: 'linkTwo',
                    title: '引入2',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initTwo != null && row.initTwo != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initTwo_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initTwo_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            } else {
                                actions += '<select  class=\'form-control\' id="initTwo_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initTwo_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            }
                            for (var i in row.linkTwoOptions) {
                                var obj = row.linkTwoOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_2_' + row.childId + '"></span>';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('2')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'2\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }
                },
                {
                    field: 'linkThree',
                    title: '引入3',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initThree != null && row.initThree != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initThree_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initThree_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            } else {
                                actions += '<select  class=\'form-control\' id="initThree_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initThree_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            }
                            for (var i in row.linkThreeOptions) {
                                var obj = row.linkThreeOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_3_' + row.childId + '"></span>';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('3')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'3\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }
                },
                {
                    field: 'linkFour',
                    title: '项目1',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initFour != null && row.initFour != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initFour_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initFour_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            } else {
                                actions += '<select  class=\'form-control\' id="initFour_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initFour_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            }
                            for (var i in row.linkFourOptions) {
                                var obj = row.linkFourOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_4_' + row.childId + '"></span>';
                        actions += '<a class="btn btn-default btn-xs allLink"  onclick="allLink(' + row.childId + ',\'initFour_\',\'' + row.initFour + '\',' + row.childCourseId + ')" type="checkbox">全员';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('4')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'4\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }
                },
                {
                    field: 'linkFive',
                    title: '项目2',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initFive != null && row.initFive != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initFive_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initFive_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            } else {
                                actions += '<select  class=\'form-control\' id="initFive_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initFive_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            }
                            for (var i in row.linkFiveOptions) {
                                var obj = row.linkFiveOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_5_' + row.childId + '"></span>';
                        actions += '<a class="btn btn-default btn-xs allLink"  onclick="allLink(' + row.childId + ',\'initFive_\',\'' + row.initFive + '\',' + row.childCourseId + ')" type="checkbox">全员';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('5')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'5\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }

                },
                {
                    field: 'linkSix',
                    title: '项目3',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initSix != null && row.initSix != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initSix_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initSix_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            } else {
                                actions += '<select  class=\'form-control\' id="initSix_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initSix_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            }
                            for (var i in row.linkSixOptions) {
                                var obj = row.linkSixOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_6_' + row.childId + '"></span>';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('6')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'6\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }

                },
                {
                    field: 'linkSeven',
                    title: '项目4',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initSeven != null && row.initSeven != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initSeven_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initSeven_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            } else {
                                actions += '<select  class=\'form-control\' id="initSeven_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initSeven_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            }
                            for (var i in row.linkSevenOptions) {
                                var obj = row.linkSevenOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_7_' + row.childId + '"></span>';
                        if(row.showDifficultyList.length >0 && row.showDifficultyList.indexOf('7')>-1){
                            actions += '<a class="btn btn-default btn-xs showDifficulty"  onclick="difficultyClick(' + row.id + ',' + row.childId + ',\'7\',' + row.intAge + ')" type="checkbox">难';
                        }
                        return actions;
                    }

                },
                {
                    field: 'linkEight',
                    title: '游戏',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initEight != null && row.initEight != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initEight_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initEight_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            } else {
                                actions += '<select  class=\'form-control\' id="initEight_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initEight_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';

                            }
                            for (var i in row.linkEightOptions) {
                                var obj = row.linkEightOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_8_' + row.childId + '"></span>';
                        actions += '<a class="btn btn-default btn-xs allLink"  onclick="allLink(' + row.childId + ',\'initEight_\',\'' + row.initEight + '\',' + row.childCourseId + ')" type="checkbox">全员';
                        return actions;
                    }

                },
                {
                    field: 'linkNine',
                    title: '按摩/拉伸',
                    formatter: function (value, row, index) {
                        var actions = '';
                        if (row.initNine != null && row.initNine != '') {
                            if (value == null || value == "") {
                                actions += '<select  class=\'form-control link-require\' id="initNine_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initNine_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            } else {
                                actions += '<select  class=\'form-control\' id="initNine_' + row.childId + '" onchange="saveProject(' + row.childId + ',\'initNine_\',' + row.id + ',' + row.childCourseId + ')"><option value="">请选择</option>';
                            }
                            for (var i in row.linkNineOptions) {
                                var obj = row.linkNineOptions[i];
                                if (obj.leafType == 2) {
                                    actions += '<optgroup label="--' + obj.projectName + '--">';
                                    var childList = obj.childList;
                                    for (var j in childList) {
                                        if (childList[j].hasSelect == true) {
                                            actions += '<option value="' + childList[j].projectCode + '" selected>' + childList[j].projectName + '</option>';
                                        } else {
                                            actions += '<option value="' + childList[j].projectCode + '">' + childList[j].projectName + '</option>';
                                        }

                                    }
                                    actions += '</optgroup>';
                                }
                                if (obj.leafType == 4) {
                                    if (obj.hasSelect == true) {
                                        actions += '<option value="' + obj.projectCode + '" selected>' + obj.projectName + '</option>';
                                    } else {
                                        actions += '<option value="' + obj.projectCode + '">' + obj.projectName + '</option>';
                                    }
                                }
                            }
                        }
                        actions += '</select>';
                        actions += '<span class="complete-times" id="complete_9_' + row.childId + '"></span>';
                        actions += '<a class="btn btn-default btn-xs allLink"  onclick="allLink(' + row.childId + ',\'initNine_\',\'' + row.initNine + '\',' + row.childCourseId + ')" type="checkbox">全员';
                        return actions;
                    }

                },

                // {
                //     title: '基础表现',
                //     align: 'center',
                //     formatter: function (value, row, index) {
                //         var actions = [];
                //         actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="viewBasicExpression(' + row.childCourseId + ',' + row.childId + ')">基础表现</a> ');
                //         return actions.join('');
                //     }
                // }
            ]
        };
        $.table.init(options);
    });

    function saveTrainAmount(childId, link, id) {
        var trainAmount = $("#" + link + "trainAmount_" + childId + "").val();
        var reqData = {
            "childId": childId,
            "id": id
        };
        if (link == 'initOne_') {
            reqData.trainAmountOne = trainAmount;
        }
        if (link == 'initTwo_') {
            reqData.trainAmountTwo = trainAmount;
        }
        if (link == 'initThree_') {
            reqData.trainAmountThree = trainAmount;
        }
        if (link == 'initFour_') {
            reqData.trainAmountFour = trainAmount;
        }
        if (link == 'initFive_') {
            reqData.trainAmountFive = trainAmount;
        }
        if (link == 'initSix_') {
            reqData.trainAmountSix = trainAmount;
        }
        if (link == 'initSeven_') {
            reqData.trainAmountSeven = trainAmount;
        }
        if (link == 'initEight_') {
            reqData.trainAmountEight = trainAmount;
        }
        if (link == 'initNine_') {
            reqData.trainAmountNine = trainAmount;
        }


        //保存选择项目
        $.ajax({
            url: ctx + "business/courseChildProject/saveTrainAmount",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify(reqData),
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                $.table.refresh();
            }
        })
    }

    function allLink(childId, link, initProject, childCourseId) {
        // var checkStr = $("#allLink_" + link + childId + "").is(':checked');
        // if(checkStr){
        var projectCode = $("#" + link + childId + "").val();
        var reqData = {
            "childCourseId": childCourseId,
            "projectCode": projectCode,
            "initProject": initProject
        };
        console.log(projectCode)
        if (link == 'initOne_') {
            reqData.linkOne = projectCode;
            reqData.linkNo = 1;
        }
        if (link == 'initTwo_') {
            reqData.linkTwo = projectCode;
            reqData.linkNo = 2;
        }
        if (link == 'initThree_') {
            reqData.linkThree = projectCode;
            reqData.linkNo = 3;
        }
        if (link == 'initFour_') {
            reqData.linkFour = projectCode;
            reqData.linkNo = 4;
        }
        if (link == 'initFive_') {
            reqData.linkFive = projectCode;
            reqData.linkNo = 5;
        }
        if (link == 'initSix_') {
            reqData.linkSix = projectCode;
            reqData.linkNo = 6;
        }
        if (link == 'initSeven_') {
            reqData.linkSeven = projectCode;
            reqData.linkNo = 7;
        }
        if (link == 'initEight_') {
            reqData.linkEight = projectCode;
            reqData.linkNo = 8;
        }
        if (link == 'initNine_') {
            reqData.linkNine = projectCode;
            reqData.linkNo = 9;
        }
        $.ajax({
            url: ctx + "business/courseChildProject/saveAllLink",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify(reqData),
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                // $("#" + link + childId + "").removeClass("link-require");
                $.table.refresh();
            }
        })
        // }
    }

    function saveProject(childId, link, id, childCourseId) {
        var projectCode = $("#" + link + childId + "").val();
        var reqData = {
            "childId": childId,
            "childCourseId": childCourseId,
            "id": id,
            "linkNo": 0,
            "projectCode": projectCode
        };
        if (link == 'initOne_') {
            reqData.linkOne = projectCode;
            reqData.linkNo = 1;
        }
        if (link == 'initTwo_') {
            reqData.linkTwo = projectCode;
            reqData.linkNo = 2;
        }
        if (link == 'initThree_') {
            reqData.linkThree = projectCode;
            reqData.linkNo = 3;
        }
        if (link == 'initFour_') {
            reqData.linkFour = projectCode;
            reqData.linkNo = 4;
        }
        if (link == 'initFive_') {
            reqData.linkFive = projectCode;
            reqData.linkNo = 5;
        }
        if (link == 'initSix_') {
            reqData.linkSix = projectCode;
            reqData.linkNo = 6;
        }
        if (link == 'initSeven_') {
            reqData.linkSeven = projectCode;
            reqData.linkNo = 7;
        }
        if (link == 'initEight_') {
            reqData.linkEight = projectCode;
            reqData.linkNo = 8;
        }
        if (link == 'initNine_') {
            reqData.linkNine = projectCode;
            reqData.linkNo = 9;
        }

        //保存选择项目
        $.ajax({
            url: ctx + "business/courseChildProject/saveProject",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            data: JSON.stringify(reqData),
            error: function (request) {
                $.modal.alertError("系统错误");
            },
            success: function (data) {
                // $("#" + link + childId + "").removeClass("link-require");
                $.table.refresh();
            }
        })
    }

    function viewBasicExpression(courseId, child) {
        // var url = ctx + "business/prepareClass/viewBasicExpression/" + courseId+"/"+child;
        // $.modal.open("基础表现", url,1200,480);
        // $.table.refresh();
        var url = ctx + "business/courseChildScore/editBasicExpression/" + courseId + "/" + child;
        $.modal.open("基础表现", url, 1200, 780);
        $.table.refresh();
    }


    function completePrepare() {
        $.ajax({
            url: prefix + "/completePrepare?childCourseId=" + $("#childCourseId").val(),
            type: "post",
            success: function (result) {
                $.modal.alertSuccess("保存成功");
            }
        })
    }

    function replaceInitLink() {
        var url = ctx + "business/prepareClass/replaceInitLink/" + $("#childCourseId").val() + "/" + $("#ageGrade").val();
        $.modal.open("替换项目", url, '800', '500');
    }
    function difficultyClick(childProjectId,childId, linkNo, age) {
        var url = ctx + "business/prepareClass/replaceDifficulty/" + childProjectId + "/"+childId+"/" + age+"/"+linkNo;
        $.modal.open("替换项目", url, '800', '400');
    }
</script>
</body>

</html>